package org.apache.jsp.ForumHtml;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.apache.jsp.ForumHtml.notifier_jsp;

public final class notifications_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final javax.servlet.jsp.JspFactory _jspxFactory =
          javax.servlet.jsp.JspFactory.getDefaultFactory();

  private static java.util.List<java.lang.String> _jspx_dependants;

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.tomcat.InstanceManager _jsp_instancemanager;

  public java.util.List<java.lang.String> getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
  }

  public void _jspDestroy() {
  }

  public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
        throws java.io.IOException, javax.servlet.ServletException {

    final javax.servlet.jsp.PageContext pageContext;
    javax.servlet.http.HttpSession session = null;
    final javax.servlet.ServletContext application;
    final javax.servlet.ServletConfig config;
    javax.servlet.jsp.JspWriter out = null;
    final java.lang.Object page = this;
    javax.servlet.jsp.JspWriter _jspx_out = null;
    javax.servlet.jsp.PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html; charset=windows-1255");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n");
      out.write("\r\n");
      out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\r\n");
      out.write("<html>\r\n");
      out.write("<head>\r\n");
      out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1255\">\r\n");
      out.write("<title>Insert title here</title>\r\n");
      out.write("</head>\r\n");
      out.write("<body>\r\n");
      out.write("<script type=\"text/javascript\" src=\"jquery.js\"></script>\r\n");
      out.write("<script type=\"text/javascript\">\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("setInterval(function() {\r\n");
      out.write("\t\r\n");
      out.write("\t\r\n");
      out.write("\r\n");
      out.write("\t$.ajax({\r\n");
      out.write("\t\ttype : \"GET\",\r\n");
      out.write("\t\turl : \"notifier.jsp\",\r\n");
      out.write("\t\tasync:false,\r\n");
      out.write("\t\tsuccess : parseXml\r\n");
      out.write("\t});\r\n");
      out.write("}, 5000);\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("function parseXml(xml)\r\n");
      out.write("{\r\n");
      out.write("\t var msg = \"\";\r\n");
      out.write("\t var reason =\"\";\r\n");
      out.write("\t targetFrame = window.parent.frames[0].document;\r\n");
      out.write("  //find every Tutorial and print the author\r\n");
      out.write("  $(xml).find(\"MSG\").each(function()\r\n");
      out.write("  {\r\n");
      out.write("\t  msg = \"\";\r\n");
      out.write("\t  switch (parseInt($(this).find(\"REASON\").text())){\r\n");
      out.write("\t  case ");
      out.print(notifier_jsp.CREATORS_TOPIC_UPDATED);
      out.write(": \r\n");
      out.write("\t  \t\t\treason = \"one of your topics has updated\";\r\n");
      out.write("\t  \t\t\tbreak;\r\n");
      out.write("\t  case ");
      out.print(notifier_jsp.FRIEND_ADDED_POST);
      out.write(": \r\n");
      out.write("\t\t  \t\treason = \"Your friend added new post\";\r\n");
      out.write("\t  \t\t\tbreak;\r\n");
      out.write("\t  case ");
      out.print(notifier_jsp.FRIEND_UPDATED_POST);
      out.write(": \r\n");
      out.write("\t  \t\treason = \"Your friend updated a post\";\r\n");
      out.write("\t\t\tbreak;\r\n");
      out.write("\t\r\n");
      out.write("\t  case ");
      out.print(notifier_jsp.FRIEND_DELETED_POST);
      out.write(": \r\n");
      out.write("\t  \t\treason = \"Your friend deleted a post\";\r\n");
      out.write("\t\t\tbreak;\t\r\n");
      out.write("\t\r\n");
      out.write("\t  case ");
      out.print(notifier_jsp.NEW_POST_IN_CURRENT_TOPIC);
      out.write(": \r\n");
      out.write("\t  \t\treason = \"New post has added to the topic that you are looking at\";\r\n");
      out.write("\t  \t\t//alert(\"inside\");\r\n");
      out.write("\t  \t\tif ($(this).find(\"USER\").text()==\"");
      out.print(session.getAttribute("userName"));
      out.write("\")\r\n");
      out.write("\t  \t\t\treturn true;\r\n");
      out.write("\t  \t\t\r\n");
      out.write("\t  \t\tif ($(\"table\",targetFrame).length == 0)\r\n");
      out.write("\t  \t\t\treturn true;\r\n");
      out.write("\t  \t\t\r\n");
      out.write("\t  \t\tvar ebutton =\"\";\r\n");
      out.write("\t  \t\tvar dbutton = \"\";\r\n");
      out.write("\t\t\tvar user = \"");
      out.print((String)session.getAttribute("userName"));
      out.write("\";\r\n");
      out.write("\t  \t\tvar permission = \"");
      out.print((String)session.getAttribute("permission"));
      out.write("\";\r\n");
      out.write("\t  \t\tvar pid = $(this).find(\"POSTID\").text();\r\n");
      out.write("\t  \t\t\r\n");
      out.write("\t  \t\tif ((permission==\"ADMIN\")||(user == $(this).find(\"USER\").text()))\r\n");
      out.write("\t  \t\t\t{\r\n");
      out.write("\t  \t\t\t\tebutton = \"<td id=edit\"+$(this).find(\"POSTID\").text()+\"><input type=button onClick=\"+\"procLink(\"+\"'\"+pid+\"') value='edit post'>\";\r\n");
      out.write("\t  \t\t\t\tdbutton = \"<br/><input type=button onClick=\"+\"removePost(\"+\"'\"+pid+\"') value='delete'></td>\";\r\n");
      out.write("\t  \t\t\t}\r\n");
      out.write("\t  \t\t\t\r\n");
      out.write("\t  \t\t\r\n");
      out.write("\t  \t\tvar row = \"<tr id=\"+$(this).find(\"POSTID\").text()+\">\"+\r\n");
      out.write("\t  \t\t\t\t\t\t\t\"<td id=title\"+$(this).find(\"POSTID\").text()+\">\"+$(this).find(\"POST\").text()+\"</td>\"+\r\n");
      out.write("\t  \t\t\t\t\t\t\t\"<td id=content\"+$(this).find(\"POSTID\").text()+\"><textarea readonly='readonly'>\"+$(this).find(\"POSTCONTENT\").text()+\"</textarea></td>\"+\r\n");
      out.write("\t  \t\t\t\t\t\t\t\"<td id=creator\"+$(this).find(\"POSTID\").text()+\">\"+$(this).find(\"CREATOR\").text()+\"</td>\"+\r\n");
      out.write("\t  \t\t\t\t\t\t\t\"<td id=creation\"+$(this).find(\"POSTID\").text()+\">\"+$(this).find(\"CREATION\").text()+\"</td>\"+\r\n");
      out.write("\t  \t\t\t\t\t\t\t\"<td id=editing\"+$(this).find(\"POSTID\").text()+\">\"+$(this).find(\"EDITING\").text()+\"</td>\"+\r\n");
      out.write("\t  \t\t\t\t\t\t\tebutton+dbutton+\r\n");
      out.write("\t  \t\t\t\t\t\"</tr>\";\r\n");
      out.write("\t\t\t\r\n");
      out.write("\t  \t\t\r\n");
      out.write("\t  \t\t\r\n");
      out.write("\t  \t\t$(\"table\",targetFrame).append(row);\r\n");
      out.write("\t        return true;\r\n");
      out.write("\t\t//\tbreak;\r\n");
      out.write("\t  case ");
      out.print(notifier_jsp.POST_UPDATED_IN_CURRENT_TOPIC);
      out.write(": \r\n");
      out.write("\t  \t\treason = \"post has been updated in the topic that you are looking at\";\r\n");
      out.write("\t\t\t\r\n");
      out.write("\t \t\t if ($(this).find(\"USER\").text()==\"");
      out.print(session.getAttribute("userName"));
      out.write("\")\r\n");
      out.write("\t\t\treturn true;\r\n");
      out.write("\t \t\t \r\n");
      out.write("\t \t\tif ($(\"#\"+$(this).find(\"POSTID\").text(),targetFrame).length == 0)\r\n");
      out.write("\t  \t\t\treturn true;\r\n");
      out.write("\t \t\t\r\n");
      out.write("\t \t\t\r\n");
      out.write("\t \t\tvar ebutton =\"\";\r\n");
      out.write("\t\t\tvar user = \"");
      out.print((String)session.getAttribute("userName"));
      out.write("\";\r\n");
      out.write("\t  \t\tvar permission = \"");
      out.print((String)session.getAttribute("permission"));
      out.write("\";\r\n");
      out.write("\t  \t\tvar pid = $(this).find(\"POSTID\").text();\r\n");
      out.write("\t  \r\n");
      out.write("\t  \t\t\r\n");
      out.write("\t  \t\tif ((permission==\"ADMIN\")||(user == $(this).find(\"CREATOR\").text()))\r\n");
      out.write("\t  \t\t\t{\r\n");
      out.write("\t  \t\t\t\tebutton = \"<input type=button onClick=\"+\"procLink(\"+\"'\"+pid+\"') value='edit post'>\"+\r\n");
      out.write("\t  \t\t\t\t\"<br/><input type=button onClick=\"+\"removePost(\"+\"'\"+pid+\"') value='delete'>\";\r\n");
      out.write("\t  \t\t\t}\r\n");
      out.write("\t \t\t\r\n");
      out.write("\t \t\t\r\n");
      out.write("\t \t\t\r\n");
      out.write("\t  \r\n");
      out.write("\t  \t\t$(\"#title\"+$(this).find(\"POSTID\").text(),targetFrame).html($(this).find(\"POST\").text()); \r\n");
      out.write("\t  \t\t$(\"#content\"+$(this).find(\"POSTID\").text(),targetFrame).html(\"<textarea readonly='readonly'>\"+$(this).find(\"POSTCONTENT\").text()+\"</textarea>\");\r\n");
      out.write("\t  \t\t$(\"#creator\"+$(this).find(\"POSTID\").text(),targetFrame).html($(this).find(\"CREATOR\").text());\r\n");
      out.write("\t  \t\t$(\"#creation\"+$(this).find(\"POSTID\").text(),targetFrame).html($(this).find(\"CREATION\").text());\r\n");
      out.write("\t  \t\t$(\"#editing\"+$(this).find(\"POSTID\").text(),targetFrame).html($(this).find(\"EDITING\").text());\r\n");
      out.write("\t  \t\t\r\n");
      out.write("\t  \t\t\r\n");
      out.write("\t  \t\tif ($(\"#edit\"+$(this).find(\"POSTID\").text(),targetFrame).length != 0)\r\n");
      out.write("\t  \t\t\t{\r\n");
      out.write("\t  \t\t\t\t\r\n");
      out.write("\t  \t\t\t\t\r\n");
      out.write("\t  \t\t\t\t$(\"#edit\"+$(this).find(\"POSTID\").text(),targetFrame).html(ebutton);\r\n");
      out.write("\t  \t\t\t}\r\n");
      out.write("\t  \t\t\t\r\n");
      out.write("\t  \t\treturn true;\r\n");
      out.write("\t  \t\t//break;\r\n");
      out.write("\t  \t\t\r\n");
      out.write("\t  case ");
      out.print( notifier_jsp.POST_DELETED_IN_CURRENT_TOPIC);
      out.write(": \r\n");
      out.write("\t  \t\treason = \"post has deleted  in the topic that you are looking at\";\r\n");
      out.write("\t\t\t$(\"#\"+$(this).find(\"POSTID\").text(),targetFrame).remove()\r\n");
      out.write("\t  \r\n");
      out.write("\t  \t\treturn true;\r\n");
      out.write("\t  \t\t//break;\r\n");
      out.write("\t  \t\t\r\n");
      out.write("\t  \r\n");
      out.write("\t  default : alert(\"big problem\");\r\n");
      out.write("\t  }\r\n");
      out.write("\t  \r\n");
      out.write("\t  \r\n");
      out.write("\t\tvar currentDate = new Date();\r\n");
      out.write("\t\t  var day = currentDate.getDate();\r\n");
      out.write("\t\t  var month = currentDate.getMonth();\r\n");
      out.write("\t\t  var year = currentDate.getFullYear();\r\n");
      out.write("\t\t  var hours = currentDate.getHours();\r\n");
      out.write("\t  \t\tvar minutes = currentDate.getMinutes();\r\n");
      out.write("\r\n");
      out.write("\t  \t\tif (minutes < 10)\r\n");
      out.write("\t  \t\tminutes = \"0\" + minutes;\r\n");
      out.write("\t\t\tvar time = day + \"/\" + month + \"/\" + year + \" \"+ hours + \":\" + minutes;\r\n");
      out.write("\t\t\t//alert(time);\r\n");
      out.write("\t  \r\n");
      out.write("\t  \r\n");
      out.write("\t  \r\n");
      out.write("\t  msg+= time+\" - \"+reason+\".\\n\";\r\n");
      out.write("\t \r\n");
      out.write("\r\n");
      out.write("\t msg+= \"user : \"+$(this).find(\"USER\").text()+\".\\n\";\r\n");
      out.write("\t msg+= \"in forum : \"+$(this).find(\"FORUM\").text()+\".\\n\";\r\n");
      out.write("\t msg+= \"In topic : \"+$(this).find(\"TOPIC\").text()+\".\\n\";\r\n");
      out.write("\t msg+= \"Post title = \"+$(this).find(\"POST\").text()+\".\\n\\n\";\r\n");
      out.write("\t $(\"<option value=posts.jsp?topicId=\"+$(this).find(\"TOPICID\").text()+\"&topicName=\"+$(this).find(\"TOPIC\").text()+\"&forumId=\"+$(this).find(\"FORUMID\").text()+\">\"+msg+\"</option>\").appendTo(\"#ComboBox\");\r\n");
      out.write("\t $(\"#ComboBox option:last\").attr('selected',true);\r\n");
      out.write("\t $(\"#goToPost\").attr('disabled', false);\r\n");
      out.write("\t \r\n");
      out.write("  });\r\n");
      out.write(" \r\n");
      out.write("  if (msg!=\"\")\r\n");
      out.write("\t  {\r\n");
      out.write("\t  //alert(msg);\r\n");
      out.write("\t \t\r\n");
      out.write("\t  }\r\n");
      out.write("\t  \r\n");
      out.write("\r\n");
      out.write("}\r\n");
      out.write("\r\n");
      out.write("$(document).ready(function() {\r\n");
      out.write("\t$(\"#goToPost\").attr('disabled', true);\r\n");
      out.write("\t\r\n");
      out.write("\t$(\"#ComboBox\").change(function() {\r\n");
      out.write("\t\t\r\n");
      out.write("\t\tif (!$(\"#ComboBox option:selected\").length)\r\n");
      out.write("\t\t\t$(\"#goToPost\").attr('disabled', true);    \r\n");
      out.write("\t\telse\r\n");
      out.write("\t\t\t$(\"#goToPost\").attr('disabled', false);\r\n");
      out.write("\t\t});\r\n");
      out.write("\t\r\n");
      out.write("\t$(\"#goToPost\").click(function() {\r\n");
      out.write("\t\t  //alert( $(\"#ComboBox\").val());\r\n");
      out.write("\t\t  window.open ($(\"#ComboBox\").val(), 'leftside');\r\n");
      out.write("\r\n");
      out.write("\t\t});\r\n");
      out.write("\t\r\n");
      out.write("\r\n");
      out.write("  \r\n");
      out.write("\t\r\n");
      out.write("\t});\r\n");
      out.write("\t\r\n");
      out.write("\t\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("</script>\r\n");
      out.write("\r\n");
      out.write("<h1> USER: ");
      out.print(session.getAttribute("userName") );
      out.write(" is logged in.</h1>\r\n");
      out.write("<h2>pemission: ");
      out.print((String)session.getAttribute("permission"));
      out.write("</h2>\r\n");
      out.write("<p>notification box</p>\r\n");
      out.write("<select id=\"ComboBox\" size=4>\r\n");
      out.write("        \r\n");
      out.write("</select>\r\n");
      out.write("<button id=goToPost type=\"button\">go</button>\r\n");
      out.write("\r\n");
      out.write("</body>\r\n");
      out.write("</html>");
    } catch (java.lang.Throwable t) {
      if (!(t instanceof javax.servlet.jsp.SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
